
<div style="POSITION: relative" id="content">
<h3>easyui DWR加载 </h3>
<div id="article_content" class="article_content">
  <h4 style="font-size:16px; color:rgb(204,0,0); margin:10px 0px; font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; text-align:left"> 引入 'dwrloader.js'</h4>
  <div>为easyui使用DWR 获得数据,首先引入 'dwrloader.js'文件.</div>
  <div><span style="font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; font-size:14px; text-align:left"><span style="font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; font-size:14px; text-align:left"><span style="font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; font-size:14px; text-align:left"></span></span></span>
    <pre name="code" class="html">&lt;script type=&quot;text/javascript&quot; src=&quot;../../jquery-1.8.0.min.js&quot;&gt;&lt;/script&gt;  
&lt;script type=&quot;text/javascript&quot; src=&quot;../../jquery.easyui.min.js&quot;&gt;&lt;/script&gt;  
&lt;script type=&quot;text/javascript&quot; src=&quot;dwrloader.js&quot;&gt;&lt;/script&gt;  </pre>
    <h4 style="font-size:16px; color:rgb(204,0,0); margin:10px 0px; font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; text-align:left"> 指定DWR方法到'url'属性</h4>作为默认的json加载,'url' 属性指明远程的URL 去检索json数据,当使用DWR 加载的时候,我们应该分配一个函数到'url' 属性去从DWR检索数据,以下是一个示例这个展示如何通过dwr加载datagrid.
  </div>

    <pre name="code" class="javascript">&lt;table id=&quot;dg&quot;&gt;&lt;/table&gt;  
$(function(){  
    $('#dg').datagrid({  
        columns: [[  
            {field:&quot;id&quot;,title:'ID',width:80},  
            {field:&quot;text&quot;,title:'Text',width:100}  
        ]],  
        singleSelect: true,  
        autoRowHeight: false,  
        width: 200,  
        height: 200,  
        url: MyTest.getDataGridData  
    });  
});  </pre>
    <h4 style="font-size:16px; color:rgb(204,0,0); margin:10px 0px; font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; text-align:left"> Java服务器测试代码</h4>
    <pre name="code" class="java">public class Test {  
    public List&lt;Map&lt;String,Object&gt;&gt; getDataGridData(){  
        List&lt;Map&lt;String,Object&gt;&gt; items = new ArrayList&lt;Map&lt;String,Object&gt;&gt;();  
        Map&lt;String,Object&gt; item = new HashMap&lt;String,Object&gt;();  
        item.put(&quot;id&quot;, 1);  
        item.put(&quot;text&quot;, &quot;text1&quot;);  
        items.add(item);  
        item = new HashMap&lt;String,Object&gt;();  
        item.put(&quot;id&quot;, 2);  
        item.put(&quot;text&quot;, &quot;text2&quot;);  
        items.add(item);  
        return items;  
    }  
} </pre>
    <h4 style="font-size:16px; color:rgb(204,0,0); margin:10px 0px; font-family:Arial,Helvetica,'Nimbus Sans L',sans-serif; text-align:left"> 下载 &nbsp;EasyUI 扩展代码:</h4>
    <div> <a href="http://www.jeasyui.com/extension/downloads/jquery-easyui-dwrloader.zip" target="_blank" class="download-link" style="color:rgb(0,0,255)">jquery-easyui-dwrloader.zip</a></div>
    <br>
  </div>
</div>
<SCRIPT type=text/javascript>
	dp.SyntaxHighlighter.ClipboardSwf = 'documentation/js/clipboard.swf'/*tpa=http://jeasyui.com/SyntaxHighlighter/Scripts/clipboard.swf*/;
	dp.SyntaxHighlighter.HighlightAll('code');
</SCRIPT>